﻿using System;
using System.Collections.Generic;
using System.Common.Extensions;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using Infinity.Common.Extensions;
using Infinity.Common.Logger;
using Infinity.Expressions.ExpressionFactory;
using Infinity.Parser.Lexical;
using Infinity.Parser.Syntax;
using Infinity.Statements.StatementFactory;
using Infinity.Types;
using Infinity.Types.Ranges;

namespace Infinity.Language.Demo
{
	class Program
	{
		static void Main(string[] args)
		{
			//SubType<string> NotEmptyString = new SubType<string>(str => !string.IsNullOrEmpty(str));

			//SubType<int> LazyInt = new SubType<int>(num => num % 2 == 0);

			//SubType<SubType<int>> intMod2 = new SubType<SubType<int>>(num => num % 2 == 0);

			//var newLazyType = SubType.UnionTypes<int, string>(LazyInt, NotEmptyString);

			//Console.WriteLine("4: {0}", LazyInt.IsElementOf(4));
			//Console.WriteLine("3: {0}", LazyInt.IsElementOf(3));
			//Console.WriteLine("Üres sztring: {0}", NotEmptyString.IsElementOf(string.Empty));
			//Console.WriteLine("Sztring: {0}", NotEmptyString.IsElementOf("lkj"));

			//Console.WriteLine();

			//Console.WriteLine("4: {0}", newLazyType.IsElementOf(4));
			//Console.WriteLine("3: {0}", newLazyType.IsElementOf(3));
			//Console.WriteLine("Üres sztring: {0}", newLazyType.IsElementOf(string.Empty));
			//Console.WriteLine("Sztring: {0}", newLazyType.IsElementOf("lkj"));

			//SubType<int> positiveNumber = new SubType<int>(num => num > 0);

			//try
			//{
			//    positiveNumber.Value = 4;
			//    Console.WriteLine(positiveNumber);
			//    positiveNumber.Value = 0;
			//    Console.WriteLine(positiveNumber);
			//}
			//catch (Exception ex)
			//{
			//    Console.WriteLine(ex.Message);
			//}

			//CharRange range = new CharRange('a','w');

			//foreach (var index in range)
			//{
			//    Console.WriteLine(index);
			//}

			//LazySet<int> lazySet = new LazySet<int>(new IntegerRange(10, by: 1), x => x % 3 == 0);

			//Console.WriteLine("LazySet: ");

			//foreach (var obj in lazySet)
			//{
			//    Console.WriteLine(obj);
			//}

			/*if (args.Length == 0)
				args = new string[] { "demo.inf2" };

			if (args.Length > 0 && File.Exists(args.First()))	
			{
				var lexicalParser = new LexicalParser();
				lexicalParser.SetSource(File.OpenRead(args.First()));

				var codeFactory = new StatementFactory();
				codeFactory.ExpressionFactory.Logger = new HtmlLogger("log.html") {Title = "Compiling " + args.First()};

				var parser = new Infinity.Parser.Syntax.SyntaxParser(lexicalParser, codeFactory);
				parser.Parse();
			}
			else
			{
				Console.WriteLine("Kérem adjon meg egy olvasandó fájlt!");
			}  */

			/*var htmlLogger = new HtmlLogger("log.html");

			var logger = MultiLogger.Create(new FileLogger("log.txt"), DebugLogger.Instance, ConsoleLogger.Instance, htmlLogger);
			logger.Flush();
			logger.Info("Hello World!");
			logger.Error("Hello World!");
			logger.Warning("Hello World!");
			100.Times(x => logger.Alert(x.ToString() + ". Hello World!")); */

			"Full: {0} Position: {Position} Age: {1.Age}; Name: {1.Name}".FormatExtended(new {Position = "employee"},
			                                                                             new {Age = 22, Name = "Tamas Szabo"});
		}
	}
}
